package com.gtd.account

import com.gtd.account.user.UserService

class AccountService implements IAccountService {
	def data
	def success
	def error

	def AccountService() {
	}

	def create(params) {
		def userService = new UserService()
		def succeeded = userService.create(params)
		if (succeeded) {
			success = [
        code: userService.code,
        message: userService.message
      ]
			data = userService.getPresent(userService.data)
			return true
		} else {
			error = [
        code: userService.code,
        message: userService.message
      ]
			return false
		}
	}

	def authenticate(params) {
    def userService = new UserService()
    if (userService.authenticate(params)) {
      success = [
        code: userService.code,
        message: userService.message
      ]
      data = userService.data
      return true
    } else {
      error = [
        code: userService.code,
        message: userService.message
      ]
      return false
    }

	}

	def activate(params) {

	}

	def changePassword(params) {

	}

	def resetPassword(params) {

	}

  /*Testing*/
  def get() {
    // root only
    def userService = new UserService()
    def userList = userService.get()
    data = userService.getListPresent(userList)
    return true
  }

}